{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "8e1e076e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "import shutil\n",
    "os.system(\"ping www.baidu.com\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "87e7eee1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'D:\\\\pythonAI\\\\my_test'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "79422115",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['.idea',\n",
       " '.ipynb_checkpoints',\n",
       " 'main.py',\n",
       " 'make_50.py',\n",
       " 'python_break_continue.ipynb',\n",
       " 'python_dict.ipynb',\n",
       " 'python_list.ipynb',\n",
       " 'python_OS操作系统文件目录.ipynb',\n",
       " 'python_tuple.ipynb',\n",
       " 'python_while_for.ipynb',\n",
       " 'test.ipynb',\n",
       " 'test2.ipynb',\n",
       " '切片.ipynb',\n",
       " '条件判断语句.ipynb']"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.listdir(os.getcwd())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "c30a46de",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d = './test'\n",
    "os.listdir(d)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "83c24510",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a.txt\n",
      "1.txt\n",
      "b.txt\n",
      "b.txt\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "['1.txt', 'b.txt']"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "for filename in os.listdir(d):\n",
    "    new_file=filename.replace('a','1')\n",
    "    print(filename)\n",
    "    print(new_file)\n",
    "    shutil.move(d+'/'+filename,d+'/'+new_file)\n",
    "os.listdir(d)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "ebbf5899",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'D:\\\\pythonAI\\\\my_test\\\\1.txt'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "shutil.move(d+'/1.txt',os.getcwd())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d12408e5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "my_test",
   "language": "python",
   "name": "my_test"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
